/**
 *Copyright (c) 2024 watereyes
 * safetymanagement is licensed under Mulan PubL v2.
 * You can use this software according to the terms and conditions of the Mulan
 * PubL v2.
 * You may obtain a copy of Mulan PubL v2 at:
 *          http://license.coscl.org.cn/MulanPubL-2.0
 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
 * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
 * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
 * See the Mulan PubL v2 for more details.
 */
package com.koron.scene.mapper;

import com.koron.scene.domain.DeviceCalibration;
import com.koron.scene.domain.DeviceCalibrationRelation;
import org.apache.ibatis.annotations.Param;
import org.koron.ebs.mybatis.EnvSource;

import java.util.List;

@EnvSource("_default")
public interface DeviceCalibrationMapper {

    /**
     * insert device calibration
     * @param deviceCalibration
     * @return
     */
    Integer insert(@Param("deviceCalibration") DeviceCalibration deviceCalibration);


    /**
     * delete device calibration in batch
     * @param idList
     * @return
     */
    Integer batchDetele(@Param("idList") List<String> idList);


    /**
     * update one device calibration
     * @param deviceCalibration
     * @return
     */
    Integer update(@Param("deviceCalibration") DeviceCalibration deviceCalibration);

    /**
     * query the one whose id is the given
     * @param id
     * @return
     */
    DeviceCalibration queryOne(@Param("id") String id);


    /**
     * fetch all device calibration in the given condition
     * @param responsibleEmployeeName
     * @param calibrationCorp
     * @param status
     * @param start
     * @param rows
     * @return
     */
    List<DeviceCalibration> queryByCondition(@Param("corpCode") String corpCode, @Param("title") String title, @Param("responsibleEmployeeName") String responsibleEmployeeName,
                                             @Param("calibrationCorp") String calibrationCorp, @Param("status") Integer status, @Param("start") Integer start, @Param("rows") Integer rows,@Param("keyword") String keyword);

    List<DeviceCalibration> queryAllByCondition(@Param("corpCode") String corpCode, @Param("title") String title, @Param("responsibleEmployeeName") String responsibleEmployeeName,
                                             @Param("calibrationCorp") String calibrationCorp, @Param("status") Integer status, @Param("start") Integer start, @Param("rows") Integer rows);

    /**
     * the number of device calibration complying with the condition
     * @param responsibleEmployeeName
     * @param calibrationCorp
     * @param status
     * @return
     */
    Integer countByCondition(@Param("corpCode") String corpCode, @Param("title") String title, @Param("responsibleEmployeeName") String responsibleEmployeeName,
                             @Param("calibrationCorp") String calibrationCorp, @Param("status") Integer status,@Param("keyword") String keyword);


    Integer updateCalibrationAttachment(@Param("deviceCalibrationId") String deviceCalibrationId, @Param("attachment") String attachment,
                                        @Param("previewAttachment") String previewAttachment);



    String queryCalibrationAttachment(@Param("deviceCalibrationId") String deviceCalibrationId);


    DeviceCalibrationRelation queryRelation(@Param("deviceCalibrationId") String deviceCalibrationId, @Param("deviceId") String deviceId);

    Integer updateRelation(@Param("relation") DeviceCalibrationRelation relation);

    Integer batchInsertRelation(@Param("relationList") List<DeviceCalibrationRelation> relationList);

    /**
     * 根据id 修改 检验记录的状态
     * @param id
     * @param status
     * @return
     */
    Integer updateStatus(@Param("id") String id, @Param("status") Integer status);

    Integer insertRelation(@Param("bean")DeviceCalibrationRelation bean);

    Integer queryCountRelation(@Param("deviceId")String deviceId, @Param("deviceCalibrationId")String deviceCalibrationId);

}
